<template>
  <div
    class="rank-list-container"
    :class="`${type}-rank`"
    v-if="data.length"
  >
    <div
      class="rank-item"
      v-for="(item, i) in data"
      :key="i"
      :class="i===0?'first-bg':i===1?'second-bg':i===2?'third-bg':'other-bg'"
    >
      <div class="flex-between">
        <div class="flex-ai-c">
          <span class="rank-image">{{ i + 1 }}</span>
          <span class="f-14">{{ item.name }}</span>
        </div>
        <div class="f-16 f-w ff-nf">
          {{ item.number }}
        </div>
      </div>
      <el-slider
        :show-tooltip="false"
        disabled
        :value="item.number"
        :max="max"
      />
    </div>
  </div>
  <div
    class="full-box flex-ai-c jc-c"
    v-else
  >
    <el-empty description="暂无数据" />
  </div>
</template>

<script>
export default {
  name: 'RankList',
  props: {
    type: {
      type: String,
      default: 'blue',
      validator (v) {
        return ['blue', 'yellow'].includes(v)
      }
    },
    data: {
      type: Array,
      default: () => []
    },
    max: {
      type: Number,
      default: 100
    }
  }
}
</script>

<style lang="scss" scoped>
.rank-list-container {
  padding: 12px 18px;

  .rank-item {
    &:not(:last-child) {
      margin-bottom: 10px;
    }

    &.first-bg {
      .rank-image {
        background: url("./images/red.png");
      }
    }

    &.second-bg {
      .rank-image {
        background: url("./images/orange.png");
      }
    }

    &.third-bg {
      .rank-image {
        background: url("./images/yellow.png");
      }
    }

    .rank-image {
      width: 24px;
      height: 18px;
      font-size: 12px;
      text-align: center;
      line-height: 18px;
      margin-right: 8px;
      padding-right: 3px;
      color: #fff;
    }

    ::v-deep {
      .el-slider__runway {
        background: #f8f8f9;
        margin: 6px 0;

        .el-slider__button-wrapper {
          cursor: default !important;

          .el-slider__button {
            cursor: default !important;
            border: none;
            width: 18px;
            height: 18px;
            position: relative;
            display: inline-flex;
            justify-content: center;
            align-items: center;

            &::before {
              position: absolute;
              z-index: 1;
              content: "";
              width: 12px;
              height: 12px;
              border-radius: 50%;
            }
          }
        }
      }
    }
  }

  &.blue-rank {
    .other-bg {
      .rank-image {
        background: url("./images/blue.png");
      }
    }

    ::v-deep {
      .el-slider__bar {
        background: #409eff !important;
      }

      .el-slider__button {
        background: rgba($color: #a5e8ff, $alpha: 0.2) !important;

        &::before {
          background: #dbeefd !important;
        }
      }
    }
  }

  &.yellow-rank {
    .other-bg {
      .rank-image {
        background: url("./images/light-yellow.png");
      }
    }

    ::v-deep {
      .el-slider__bar {
        background: #fed000 !important;
      }

      .el-slider__button {
        background: rgba($color: #fcf5d6, $alpha: 0.2) !important;

        &::before {
          background: #fcf5d6 !important;
        }
      }
    }
  }
}
</style>
